package util
{
	import flash.display.DisplayObject;
	import flash.geom.Point;
	import flash.utils.ByteArray;

	import globals.Global;

	/**
	 * 常用的Utils
	 * @author luguobin
	 */
	public class Utils
	{
		private static var point:Point = new Point();

		public static function getGlobalToLocal(target:DisplayObject):Point
		{
			point.x = Global.stage.mouseX;
			point.y = Global.stage.mouseY;
			return target.globalToLocal(point);
		}

		public static function getLocalToGlobal(target:DisplayObject):Point
		{
			point.x = 0;
			point.y = 0;
			return target.localToGlobal(point);
		}

		/**深度克隆类实例,但不是所有类都可以复制，例如MovieClip(不可复制)就是其中之一。**/
		public static function clone(resource:Object):Object
		{
			var byteArr:ByteArray = new ByteArray();
			byteArr.writeObject(resource);
			byteArr.position = 0;
			return byteArr.readObject() as Object;
		}
	}
}